package com.rongxun.hbwallet.ui.adapter;

import android.graphics.Color;
import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.rongxun.hbwallet.R;
import com.rongxun.hbwallet.model.bean.CandyTask;

import java.util.List;

/**
 * Created by dwq on 2018/3/13/013.
 * e-mail:lomapa@163.com
 */

public class HomeTaskAdapter extends BaseQuickAdapter<CandyTask, BaseViewHolder> {

    public HomeTaskAdapter(int layoutResId, @Nullable List<CandyTask> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, CandyTask item) {
        helper.setText(R.id.inviting_friends, item.getEvent());
        helper.setText(R.id.inviting_tv_sum, String.format(mContext.getString(R.string.candy_sum), item.getCandyNum()));


        if (item.getTodayLimit() == null) {
            helper.setTextColor(R.id.inviting_tv_state, Color.parseColor("#FF5C5D"));
            helper.setText(R.id.inviting_tv_state, String.format(mContext.getString(R.string.todayNum), item.getTodayNum()));
            helper.setVisible(R.id.inviting_iv_state, false);
        } else if (Integer.parseInt(item.getTodayLimit()) == item.getTodayNum()) {

            helper.setTextColor(R.id.inviting_tv_state, Color.GRAY);
            helper.setVisible(R.id.inviting_iv_state, true);
            helper.setText(R.id.inviting_tv_state, mContext.getString(R.string.completed));
        } else {
            helper.setTextColor(R.id.inviting_tv_state, Color.parseColor("#FF5C5D"));
            helper.setVisible(R.id.inviting_iv_state, false);
            helper.setText(R.id.inviting_tv_state, mContext.getString(R.string.not_finished));
        }

    }

}
